package com.ysd.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ysd.crm.entity.RoleModules;
import com.ysd.crm.entity.Roles;
import com.ysd.crm.mapper.RolesMapper;
import com.ysd.crm.service.RolesService;


@Service
public class RolesServiceImpl implements RolesService {
	
	@Autowired
	private RolesMapper rMapper;

	@Override
	public List<Roles> findRoles(Roles r) {
		// TODO Auto-generated method stub
		return rMapper.getRoles(r);
	}

	@Override
	public int findCount(Roles r) {
		// TODO Auto-generated method stub
		return rMapper.getCount(r);
	}

	@Override
	public int addRoles(Roles r) {
		// TODO Auto-generated method stub
		return rMapper.insertRoles(r);
	}

	@Override
	public int upRoles(Roles r) {
		// TODO Auto-generated method stub
		return rMapper.updateRoles(r);
	}

	@Override
	public Roles findName(Roles r) {
		// TODO Auto-generated method stub
		return rMapper.getName(r);
	}

	@Override
	public int delRoles(String Id) {
		// TODO Auto-generated method stub
		return rMapper.delRoles(Id);
	}

	@Override
	public List<RoleModules> getId(RoleModules r) {
		// TODO Auto-generated method stub
		return rMapper.getId(r);
	}

	/**
	 * ytt
	 * 查询所有权限
	 * @return
	 */
	@Override
	public List<Roles> findAllRoles() {
		// TODO Auto-generated method stub
		return rMapper.getAllRoles();
	}

	/**
	 * ytt
	 * 根据用户id查询角色id
	 * @param RoleId
	 * @return
	 */
	@Override
	public List<String> findUserIdByRolesId(String Id) {
		// TODO Auto-generated method stub
		return rMapper.getUserIdByRolesId(Id);
	}


	/**
	 * ytt
	 * 给用户添加角色
	 * @param UserId
	 * @param RoleId
	 * @return
	 */
	@Override
	public int insertUserRoles(String UserId, String[] RoleId) {
		// TODO Auto-generated method stub
		return rMapper.addUserRoles(UserId, RoleId);
	}

	/**
	 * ytt
	 * 给用户删除角色
	 * @param UserId
	 * @param RoleId
	 * @return
	 */
	@Override
	public int deleteUserRoles(String UserId, String[] RoleId) {
		// TODO Auto-generated method stub
		return rMapper.delUserRoles(UserId, RoleId);
	}
}
